<form action="" class="form-horizontal" role="form">

  <div class="form-group">
    <label class="col-sm-2 control-label">团购标题</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" name="name" value="{$productActivity['name']?$productActivity['name']:$productActivity['productGoodsName']}" placeholder="团购标题" datatype="*" />
      <input type="hidden" name="product_goods_id" value="{$productActivity['product_goods_id']}" />
    </div>
  </div>
  
  <div class="form-group">
    <label class="col-sm-2 control-label">开始时间</label>
    <div class="col-sm-2">
      <input type="text" id="start-time" class="form-control" name="start_time" placeholder="" datatype="*" value="{$productActivity['start_time']?date('Y-m-d h:i', $productActivity['start_time']):''}"/>
    </div>
  </div>
  
  <div class="form-group">
    <label class="col-sm-2 control-label">结束时间</label>
    <div class="col-sm-2">
      <input type="text" id="end-time" class="form-control" name="end_time" placeholder="" datatype="*" value="{$productActivity['end_time']?date('Y-m-d h:i', $productActivity['end_time']):''}"/>
    </div>
  </div>

  <if condition="$productActivity['id']">
  <div class="form-group">
    <label class="col-sm-2 control-label">是否结束</label>
    <div class="col-sm-2">
      {$productActivity['isFinishedRadio']}
    </div>
  </div>
  </if>

  <div class="form-group">
    <label class="col-sm-2 control-label">限购数量</label>
    <div class="col-sm-1">
      <input type="number" max="100000" min="0" class="form-control" name="ext_info[restriction]" placeholder="" datatype="*" value="{$productActivity['ext_info']['restriction']}" />
      <span class="label label-info">如果商品的团购数量达到这个值，那么团购活动自动结束。为0时不受限制，按超出结束时间时自动结束。</span>
    </div>
  </div>
  
  <div class="form-group">
    <label class="col-sm-2 control-label">团购说明</label>
    <div class="col-sm-4">
      <textarea name="desc" class="form-control">{$productActivity['desc']}</textarea>
    </div>
  </div>

  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-8">
      <a class="btn btn-default" onclick="javascript:history.go(-1)">返回上页</a>
      <a class="btn btn-default" onclick="self.location=document.referrer">返回上页并刷新</a>
       <input type="hidden" name="type" value="{$productActivity['type']}" />
      <input type="hidden" name="id" value="{$productActivity['id']}" />
      <button type="submit" class="btn btn-primary submit" data-loading-txt="提交中，请稍后……" data-ajax-url="__CONTROLLER__/saveActivity">保存更改</button>
    </div>
  </div>
  
</form>


<!-- datetimepicker -->
<link rel="stylesheet" href="/Public/Style/Common/datetimepicker/bootstrap-datetimepicker.min.css"/>
<script type="text/javascript" src="/Public/Style/Common/datetimepicker/bootstrap-datetimepicker.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="/Public/Style/Common/datetimepicker/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>

<script type="text/javascript">
	$("#start-time").datetimepicker({
	    format: 'yyyy-mm-dd hh:ii',
	    language: "zh-CN",
	    autoClose: true,
	    startDate: new Date()
	}).on( "changeDate", function(ev) {
		var startTime = $(this).val();
		$("#end-time").val(startTime);
		$("#end-time").datetimepicker({
			format: 'yyyy-mm-dd hh:ii',
		    language: "zh-CN",
		    autoClose: true,
		    startDate: startTime
		})	
	});
</script>
